
/**
 * Created by xiongshilin on 2017/3/29.
 */
(function(){
    VUEADF.ContentsControl = function(){
        VUEADF.ContentsControl.superclass.constructor.call(this, null);
    };
    COM.util.defineClass(VUEADF.ContentsControl, VUEADF.Composite, {
        getLabel: function() {
            return "DefaultContentsControl";
        },
        createDomElement: function() {
            var element = document.createElement("div");
            element.id = "contentscontrol";
            element.style.position="relative";
            element.style.top="0px";
            element.style.left="0px";
            element.style.width="100%";
            element.style.height="100%";
            this.domElement = element;
        },
        getVM : function(){
            return diagramVM;
        },
        appendChildData : function(childData){
            this.getVM().children.push(childData);
        },
        setWidth:function(width) {
            if(this.domElement) {
                this.domElement.style.width = width + "px";
            }
        },
        getWidth: function() {
            if(this.domElement) {
                return COM.util.HTMLUtil.getElementWidth(this.domElement);
            }
        },
        setHeight:function(height) {
            if(this.domElement) {
                this.domElement.style.height = height + "px";
            }
        },
        getHeight: function() {
            if(this.domElement) {
                return COM.util.HTMLUtil.getElementHeight(this.domElement);
            }
        },
        setSize: function(width, height) {
            if(this.domElement) {
                this.domElement.style.width = width + "px";
                this.domElement.style.height = height + "px";
            }
        },
        appendDomChild: function(domChild) {
            // COM.util.HTMLUtil.addChild(this.domElement, domChild);
        },
        removeDomChild: function(domChild) {
            // COM.util.HTMLUtil.removeChild(domChild);
        },
        getDomElement: function(){
            if(!this.domElement) {
                this.createDomElement();
            }
            return this.domElement;
        },
        layoutChild : function(child){
            var childDom = child.getDomElement();
            var layoutData = child.getLayoutData();
            if(layoutData){
                var css = {"display":"block", "position":"absolute", "left":layoutData.x + 'px', "top":layoutData.y + 'px'};
                if(layoutData.width >= 0) {
                    css.width = layoutData.width + 'px';
                }
                if(layoutData.height >= 0) {
                    css.height = layoutData.height + 'px';
                }
                $(childDom).css(css);
            }
            if(child._afterLayout){
                child._afterLayout();
            }
        }
    });
})();